<template>
    <div>
        <div class="mui-numbox" data-numbox-min="1" >
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input class="mui-input-numbox" type="number" value="1" @change = "countChange" ref="count"/>
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
        </div>
    </div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min'
export default {
    mounted(){
        //初始化数字选择框组件
        mui('.mui-numbox').numbox();
        console.log(this.max)
    },
    methods:{
        countChange(){
            console.log("当前值"+this.$refs.count.value)
            this.$emit("getCount",parseInt(this.$refs.count.value));

        },
    },
    props: ['max'],
    watch: {
        //属性监听
        max: function(newVal,oldVal) {
            mui('.mui-numbox').numbox().setOption('max',newVal);
        }
    }
}
</script>
<style lang="scss" scoped>
    
</style>
